// 后台登录表单数据
import { reactive } from 'vue'

interface LoginFormTypes {
  name: string
  pass: string
}

interface RulesTypes {
  name: (
    | {
        required: boolean
        trigger: string
        message: string
        min?: undefined
        max?: undefined
        messsage?: undefined
      }
    | {
        min: number
        max: number
        messsage: string
        trigger: string
        required?: undefined
        message?: undefined
      }
  )[]
  pass: (
    | {
        required: boolean
        trigger: string
        message: string
        min?: undefined
        max?: undefined
      }
    | {
        min: number
        max: number
        message: string
        trigger: string
        required?: undefined
      }
  )[]
}

// 登录表单数据
export const loginForm = reactive<LoginFormTypes>({
  name: '',
  pass: ''
})

export const rules = reactive<RulesTypes>({
  name: [
    {
      required: true,
      trigger: 'change',
      message: '请输入用户名'
    },
    {
      min: 2,
      max: 12,
      messsage: '用户名长度为3~12位',
      trigger: 'change'
    }
  ],
  pass: [
    {
      required: true,
      trigger: 'change',
      message: '请输入密码'
    },
    {
      min: 3,
      max: 16,
      message: '密码长度为6~12位',
      trigger: 'change'
    }
  ]
})
